import service from '@/utils/request'

export const useCommandTypeApi = (id: number) => {
  return service.get('/gps/command_type/' + id)
}

export const useCommandTypeSubmitApi = (dataForm: any) => {
  if (dataForm.predictCmdId) {
    return service.put('/gps/command_type/update', dataForm)
  } else {
    return service.post('/gps/command_type/save', dataForm)
  }
}
export const deleteCommandType = (id: number) => {
  return service.delete('/gps/command_type/delete/' + id)
}

// 获取所有设备命令
export function getAllCommand() {
  return service.get('/gps/command_type/allCmd')
}
// 获取指令类型
export function getCommandTypeApi() {
  return service.get('/gps/command_type/cmdAction')
}

// 新增指令
export function addCommand(data) {
  return service.post('/gps/command_type/save', data)
}

// 更新指令
export function updateCommand(data) {
  return service.put('/gps/command_type/update', data)
}

// 删除指令
export function delCommand(id) {
  return service.delete(`/gps/command_type/delete/${id}`)
}

// 获取设备命令列表
export function getDeviceCmd(imei) {
  return service.get('/gps/command_type/cmdForDevice', {
    params: {
      imei: imei
    }
  })
}
